@extends('admin::layouts.master')
@section('content')
    @component('components.tabs',['title' => '用户管理'])
        @slot('nav')
            <li class="nav-item">
                <a href="{{route('adminuser.index')}}" class="btn btn-space btn-success">后台用户列表</a>
            </li>
            <li class="nav-item" >
                <button data-toggle="modal" data-target="#addAdminUser" type="button" class="btn btn-space btn-primary">
                    添加后台用户
                </button>
            </li>
            {{--引入模态框组件--}}
            {{--将这个模态框变成一个组件--}}
            @component('components.modal',['title' => '添加后台用户','url' => '/admin/adminuser','id' => 'addAdminUser','style'=>'block'])
            <div class="modal-body">
            <div class="form-group">
            <label>用户名</label>
            <input type="text" name="name" placeholder="请输入后台用户登录账号!!!..." class="form-control">
            </div>
            <div class="form-group">
            <label>昵称</label>
            <input type="text" name="nickname" placeholder="请输入后台用户的昵称!!!..." class="form-control">
            </div>
            <div class="form-group">
            <label>密码</label>
            <input type="password" name="password" placeholder="请输入后台用户的登录密码!!!..."
            class="form-control">
            </div>
            </div>
            @endcomponent
            {{--引入模态框组件--}}
            @endslot
        @slot('body')
            <div class="card-body">
                <table class="table">
                <thead>
                    <tr>
                        <th width="15%">编号</th>
                        <th width="20%">用户名</th>
                        <th width="20%">昵称</th>
                        <th class="actions">操作</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($admins as $v)
                    <tr>
                    <td>{{$v['id']}}</td>
                    <td>{{$v['name']}}</td>
                    <td>{{$v['nickname']}}</td>
                    <td class="actions">
                    <div class="btn-group btn-space">
                    <button data-toggle="modal" data-target="#showRole{{$v['id']}}" type="button" class="btn btn-info">
                    查看
                    </button>
                    @component('components.modal',['title' => '查看用户资料','url' => route('adminuser.update',$v['id']),'id' => 'showRole' . $v['id'],'method' => 'PUT','style'=>'none'])
                    <div class="modal-body">
                    <div class="form-group text-left">
                    <label>用户名</label>
                    <input type="text" name="name" value="{{$v['name']}}" readonly class="form-control">
                    </div>
                    <div class="form-group text-left">
                    <label>昵称</label>
                    <input type="text" name="nickname" value="{{$v['nickname']}}" readonly class="form-control">
                    </div>
                    <div class="form-group text-left">
                    <label>密码</label>
                    <input type="password" name="password" value="" readonly class="form-control">
                    </div>
                    </div>
                    @endcomponent

                    <button data-toggle="modal" data-target="#editRole{{$v['id']}}" type="button" class="btn btn-success">
                    编辑
                    </button>
                    @component('components.modal',['title' => '编辑后台用户','url' => route('adminuser.update',$v['id']),'id' => 'editRole' . $v['id'],'method' => 'PUT','style'=>'block'])
                    <div class="modal-body">
                    <div class="form-group text-left">
                    <label>用户名</label>
                    <input type="text" name="name" value="{{$v['name']}}"
                    class="form-control">
                    </div>
                    <div class="form-group text-left">
                    <label>昵称</label>
                    <input type="text" name="nickname" value="{{$v['nickname']}}" class="form-control">
                    </div>
                    <div class="form-group text-left">
                    <label>密码</label>
                    <input type="password" name="password" value="" class="form-control">
                    </div>
                    </div>
                    @endcomponent
                    <form action="{{route('adminuser.destroy',$v['id'])}}" method="post">
                    @csrf
                    @method('DELETE')
                    <button type="submit" class="btn btn-danger">删除</button>
                    </form>
                    <a href="{{route('addrole',$v)}}" class="btn btn-warning">添加角色</a>
                    </div>
                    </td>
                    </tr>
                    @endforeach
                </tbody>
                </table>
            </div>
                <div class="card-footer text-muted">
                {{$admins->links()}}
            </div>
            @endslot
        @endcomponent
    @endsection